package com.woniu.service.impl;

import com.woniu.dao.VisitDao;
import com.woniu.service.VisitService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class VisitServiceImpl implements VisitService {


    @Autowired
    private VisitDao visitDao;

    @Override
    public void recordVisit(HttpServletRequest request) {
        // 直接调用DAO层更新数据库
        visitDao.saveOrUpdateVisitRecord(LocalDate.now());
    }

    @Override
    public int getVisitCountByDate(LocalDate date) {
        Integer count = visitDao.getVisitCountByDate(date);
        return count != null ? count : 0;  // 处理null情况
    }
}
